/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.asportoonline.tags;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 *
 * @author fe
 */
public class GiorniSettimanaTag extends SimpleTagSupport {
    private String giorno;

    public String getGiorno() {
        return giorno;
    }

    public void setGiorno(String giorno) {
        this.giorno = giorno;
    }
    
    @Override
    public void doTag() throws JspException {
        JspWriter out = getJspContext().getOut();
        String g = getGiorno();
        
        if(g == null) {
            g = "none";
        }
        
        try {
            out.print("<option value=\"none\">Scegli giorno...</option>");
            
            if(g.equals("-1")) {
                out.print("<option value=\"-1\" selected=\"selected\">Nessuno</option>");
            }
            else {
                out.print("<option value=\"-1\">Nessuno</option>");
            }

            if(g.equals("0")) {
                out.print("<option value=\"0\" selected=\"selected\">Luned&igrave;</option>");
            }
            else {
                out.print("<option value=\"0\">Luned&igrave;</option>");
            }

            if(g.equals("1")) {
                out.print("<option value=\"1\" selected=\"selected\">Marted&igrave;</option>");
            }
            else {
                out.print("<option value=\"1\">Marted&igrave;</option>");
            }
            
            if(g.equals("2")) {
                out.print("<option value=\"2\" selected=\"selected\">Mercoled&igrave;</option>");
            }
            else {
                out.print("<option value=\"2\">Mercoled&igrave;</option>");
            }
            
            if(g.equals("3")) {
                out.print("<option value=\"3\" selected=\"selected\">Gioved&igrave;</option>");
            }
            else {
                out.print("<option value=\"3\">Gioved&igrave;</option>");
            }
            
            if(g.equals("4")) {
                out.print("<option value=\"4\" selected=\"selected\">Venerd&igrave;</option>");
            }
            else {
                out.print("<option value=\"4\">Venerd&igrave;</option>");
            }
            
            if(g.equals("5")) {
                out.print("<option value=\"5\" selected=\"selected\">Sabato</option>");
            }
            else {
                out.print("<option value=\"5\">Sabato</option>");
            }
            
            if(g.equals("6")) {
                out.print("<option value=\"6\" selected=\"selected\">Domenica</option>");
            }
            else {
                out.print("<option value=\"6\">Domenica</option>");
            }
            
        } catch(IOException ex) {
            throw new JspException("Error in GiorniSettimanaTag tag", ex);
        }
    }
    
}
